import Vue from 'vue'
import App from '@/App'
import store from '@/store'

Vue.config.productionTip = false

import plugins from '@/plugins/index'
Vue.use(plugins)

import FloatMenu from '@/components/FloatMenu'
Vue.component("FloatMenu",FloatMenu);
import NavBar from '@/components/NavBar'
Vue.component("NavBar",NavBar);

Vue.mixin({
  onUnload () {
    if (this.$options.data) {
      Object.assign(this.$data, this.$options.data()) // 重置组件数据状态
    }
  },
  methods:{
    link(path){
      wx.navigateTo({
          url: "/pages"+ path
      })
    },
    link2(path){
      wx.navigateTo({
          url: "/"+ path
      })
    },
    formatDetail(detail){
      var arr = detail.split("\<img")
      arr.forEach((v, i)=>{
          if(v.indexOf('src')!=-1){
              if(v.indexOf('style')!=-1 && v.indexOf('style')< v.indexOf('>')){
                  arr[i] = v.replace('style="', 'style="max-width:100%;height:auto;').replace("style='", "style='max-width:100%;height:auto;")
              } else {
                  arr[i] = 'style="max-width:100%;height:auto" ' +arr[i]
              }
          }
      })
      return arr.join('<img ')
    },
    getSysInfo() {
      const res = wx.getSystemInfoSync()
      return res
  },
  }
})

const app = new Vue({
  store,
  ...App
})

app.$mount()
